<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------


/**
 * 前端路由
 */
Route::group('',function () {
  //首页渲染
  //Route::rule('index', 'api/view/index')->name('index');
  //Route::rule('goods', 'api/view/index')->name('goods');

  Route::get('getHomeData', 'api/index/homeData')->name('getHomeData');  //首页数据
  Route::get('search', 'api/index/search')->name('search'); //搜索

  Route::post('login', 'api/login/LoginCheck')->name('login'); //登录
  Route::post('register', 'api/login/register')->name('register'); //注册
  Route::get('sendEmailCode', 'api/login/sendEmailCode')->name('sendEmailCode'); //发送邮箱验证码

  //登录中间件
  Route::group('',function () {
    Route::get('getGoodsDetail', 'api/goods/goodsDetail')->name('getGoodsDetail');  //商品详情

    Route::post('addCart', 'api/Shopcart/addCart')->name('addCart'); //加入购物车
    Route::get('shopcartList', 'api/Shopcart/myShopcart')->name('shopcartList'); //我的购物车列表
    Route::get('delCartGoods', 'api/Shopcart/delCartGoods')->name('delCartGoods'); //删除购物车内商品
    Route::post('putQtyAndReturn', 'api/Shopcart/putQtyAndReturn')->name('putQtyAndReturn'); //购物车内商品加减

    Route::get('checkOrderInfo', 'api/order/checkOrder')->name('checkOrderInfo'); //确认订单信息
    Route::post('createOrder', 'api/order/createOrder')->name('createOrder'); //创建订单
    Route::get('getOrderList', 'api/order/orderList')->name('getOrderList'); //获取我的订单列表
    
    Route::get('getAddressList', 'api/address/addressList')->name('getAddressList'); //获取地址列表
    Route::post('addAddress', 'api/address/addAddress')->name('addAddress'); //添加地址
    Route::get('delAddress', 'api/address/delAddress')->name('delAddress'); //删除地址
    Route::get('setDefault', 'api/address/setDefault')->name('setDefault'); //设置默认地址
  })->middleware('isLogin');
});




//微商城路由
Route::group('weixin', function() {
  Route::get('/index/index', 'nideshop/index/indexAction');  //首页接口

  Route::get('/topic/list', 'nideshop/Topic/listAction');
  Route::get('/topic/detail', 'nideshop/Topic/detailAction');
  Route::get('/topic/related', 'nideshop/Topic/relatedAction');

  Route::post('/auth/loginByWeixin', 'nideshop/Auth/loginByWeixinAction');

  Route::get('/goods/list', 'nideshop/Goods/listAction'); //获得商品列表
  Route::get('/goods/count', 'nideshop/Goods/countAction'); //统计商品总数
  Route::get('/goods/detail', 'nideshop/Goods/detailAction'); //获得商品的详情
  Route::get('/goods/related', 'nideshop/Goods/relatedAction'); //商品详情页的大家都在看的商品

  Route::get('/goods/category', 'nideshop/Category/categoryAction'); //获得分类数据
  Route::get('/catalog/index', 'nideshop/Category/indexAction'); //获得分类数据
  Route::get('/catalog/current', 'nideshop/Category/currentAction'); //根据id获取详情

  Route::get('/comment/list', 'nideshop/Comment/listAction'); // 获取评论列表
  Route::get('/comment/count', 'nideshop/Comment/countAction'); // 获取评论数量

  Route::get('/region/list', 'nideshop/Region/listAction');

  Route::get('/cart/goodscount', 'nideshop/cart/goodscountAction'); //商品数量

  Route::get('/brand/list', 'nideshop/Brand/listAction');
  Route::get('/brand/detail', 'nideshop/Brand/detailAction');

  Route::get('/search/helper', 'nideshop/search/helperAction'); //搜索帮助

  //判断登录
  Route::group('',function () {
    Route::get('/cart/index', 'nideshop/cart/indexAction'); //获取购物车的数据
    Route::post('/cart/add', 'nideshop/cart/addAction'); //添加商品到购物车
    Route::post('/cart/update', 'nideshop/cart/updateAction'); //更新购物车的商品
    Route::post('/cart/delete', 'nideshop/cart/deleteAction'); //删除购物车内商品
    Route::post('/cart/checked', 'nideshop/cart/checkedAction'); //选择或取消选择商品
    Route::get('/cart/checkout', 'nideshop/cart/checkoutAction'); //下单前信息确认

    Route::get('/address/list', 'nideshop/Address/listAction'); // 获取地址列表
    Route::get('/address/detail', 'nideshop/Address/detailAction'); // 获取地址详情
    Route::post('/address/save', 'nideshop/Address/saveAction'); // 添加或更新收货地址
    Route::post('/address/delete', 'nideshop/Address/deleteAction');

    Route::post('/comment/post', 'nideshop/Comment/postAction'); // 添加评论

    Route::get('/collect/list', 'nideshop/Collect/listAction');  // 获取收藏列表
    Route::post('/collect/addordelete', 'nideshop/Collect/addordeleteAction'); //添加收藏夹

    Route::post('/order/submit', 'nideshop/order/submitAction');//提交订单
    Route::get('/order/list', 'nideshop/order/listAction'); //订单列表
    Route::get('/order/detail', 'nideshop/order/detailAction');//订单详情
    Route::get('/order/cancel', 'nideshop/order/cancelAction'); //取消订单
    Route::get('/order/express', 'nideshop/order/expressAction'); //物流详情

    Route::get('/footprint/list', 'nideshop/footprint/listAction'); //足迹列表
    Route::rule('/footprint/delete', 'nideshop/footprint/deleteAction'); //删除足迹

    Route::get('/search/index', 'nideshop/search/indexAction'); //搜索页面数据
    Route::rule('/search/clearhistory', 'nideshop/search/clearhistoryAction'); //清除历史
  })->middleware('nideshopLogin');
});
